package es.uclm.itsue.interfaces;

import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.util.Log;

import android.widget.Toast;

public class ItsueInterfacesActivity extends ListActivity {
	
	private String[] interfaceNames;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                       
        interfaceNames = getResources().getStringArray(R.array.interfaceNames);
        setListAdapter(new ArrayAdapter<String>(
				this, 
				android.R.layout.simple_list_item_1, 
				interfaceNames));

        getListView().setTextFilterEnabled(true);
    }

    @Override
  	protected void onListItemClick(ListView l, View v, int position, long id) {
    	Log.i(getPackageName(), "Pulsado item " + position + "\t" + interfaceNames[position]);
   	
    	if (interfaceNames[position].equals("Toast")) {
    		Toast.makeText(
        			this, 
        			"Este es un mensaje dentro de un bocadillo", 
        			Toast.LENGTH_LONG).show();
    	}
    	else if (interfaceNames[position].equals("TextView")) {
    		startActivity(new Intent(this,TextViewActivity.class));
    	}
    	else if (interfaceNames[position].equals("EditText")) {
    		startActivity(new Intent(this,EditTextActivity.class));
    	}
    	else if (interfaceNames[position].equals("Buttons")) {
    		startActivity(new Intent(this,ButtonsActivity.class));
    	}
    	else if (interfaceNames[position].equals("OptionsMenu")) {
    		startActivity(new Intent(this,OptionsMenuActivity.class));    		
    	}
    	else if (interfaceNames[position].equals("ContextMenu")) {
    		startActivity(new Intent(this,ContextMenuActivity.class));
    	}    	
    	else if (interfaceNames[position].equals("Dialogs")) {
    		startActivity(new Intent(this,DialogsActivity.class));
    	}
        else if (interfaceNames[position].equals("Notifications")) {
       		startActivity(new Intent(this,NotificationsActivity.class));	
    	}    	    	
	}
}
